\documentclass[a4paper]{article}
\usepackage[affil-it]{authblk}
% \usepackage[backend=bibtex,style=numeric]{biblatex}
\usepackage{amssymb}
\usepackage{amsmath}
\usepackage{geometry}
\geometry{margin=1.5cm, vmargin={0pt,1cm}}
\setlength{\topmargin}{-1cm}
\setlength{\paperheight}{29.7cm}
\setlength{\textheight}{25.3cm}

\begin{document}
% =================================================
\title{Numerical Analysis report 1}

\author{YuXiangJin 3220103054
  \thanks{Electronic address: \texttt{2621201771@qq.com}}}
\affil{XinJi 2201, Zhejiang University }


\date{Due time: \today}

\maketitle


% ============================================
\section*{A. Implement the bisection method, Newton's method, and the secant method in a C++ package.}

The EquationSolver class provides a unified interface for all solving methods.
\newline
For each specific method class, the solve function has been refactored to implement the solving functionality, with specific parameters set as private members within the method class, facilitating their application in different scenarios.
\newline
In addition, the implementation of the bisection method includes checks for user input of initial values and handling of special cases.

\section*{B. Test your implementation of the bisection method on the following functions and intervals. }

\begin{enumerate}
    \item $x^{-1} - \tan x \ on \  [0,\frac{\pi}{2}] :\ $ 
    A root is: 0.860333
    \item $x^{-1} - 2^x \ on \  [0,1]:\ $ 
    A root is: 0.641186
    \item $2^{-x} + e^x + 2\cos x - 6 \ on \  [1,3]:\ $
    A root is: 1.82938
    \item $(x^3 + 4x^2 + 3x + 5)/(2x^3 - 9x^2 +18x -2) \ on \  [0,4]:\ $
    A root is: 0.117877
\end{enumerate}

\section*{C. Test your implementation of Newton's method by solving $x = tan x$. Find the roots near $4.5$ and $7.7$.}
\begin{enumerate}
    \item A root near 4.5 is: 4.49341
    \item A root near 7.7 is: 7.72525
\end{enumerate}

\section*{D. Test your implementation of the secant method by the following functions and initial values. }

\begin{enumerate}
    \item $\sin(x/2) - 1 .$ \\
    $with \  x_0 = 1, x_1 = \frac{\pi}{2} :\ $ 
    A root is: 3.14093 \\
    $ \ with \ x_0 = 6, x_1 = 2\pi :\ $
    A root is: 3.14246

    \item $ e^x - \tan x .$ \\
    $with \  x_0 = 1, x_1 = 1.4 :\ $
    A root is: 1.30633 \\
    $ \ with \ x_0 = 1.2, x_1 = 1.5 :\ $
    A root is: 1.30633

    \item $ x^3 - 12x^2 + 3x + 1 .$ \\
    $with \  x_0 = 0, x_1 = -0.5 :\ $
    A root is: -0.188685 \\
    $ \ with \ x_0 = -1, x_1 = 0 :\ $
    A root is: -0.188685
\end{enumerate}

\section*{E. Suppose $L = 10ft, r = 1ft$, and $ V = 12.4{ft}^3$. Find the depth of water in the trough to within 0.01ft by each of the three implementations in A.}

\begin{enumerate}
    \item bisection method : \ 
    A root is: 0.166165 $\Rightarrow$ the depth of water is 0.833835.
    \item Newton method : \
    A root is: 0.166166 $\Rightarrow$ the depth of water is 0.833834.
    \item Secant method : \
    A root is: 0.166166 $\Rightarrow$ the depth of water is 0.833834.
\end{enumerate}


\section*{F. The maximum angle $\alpha$ that can be negotiated by a vehicle when $\beta$ is the maximum angle at which hang-up failure does not occur satis?es the equation
\[
A \sin \alpha \cos \alpha + B {\sin^2 \alpha} -C \cos \alpha - E \sin \alpha = 0,
\]
where
\[
A = l\sin\beta _1, B = l\cos\beta _1,
\]
\[
C = (h+0.5D)\sin\beta _1 - 0.5D\tan\beta _1,
\]
\[
E = (h+0.5D)\cos\beta _1 - 0.5D.
\]
}

\subsection*{(a)Use Newton's method to verify $\alpha \approx 33^{\circ} $ when $ l = 89\ in., h = 49\ in., D = 55\ in.\ and\  \beta _1 = 11.5^{\circ}$.
}
A root is: 0.575473. $\Rightarrow 32.972^{\circ}$.
\subsection*{(b)$D = 30\ in.$}
A root is: 0.575473. $\Rightarrow 32.972^{\circ}$.
\subsection*{(c)Use the secant method (with another initial value as far away as possbile from $33^{\circ}$) to find $\alpha$.}
\begin{enumerate}
    \item When the initial value is 70 and 80: \ 
    A root is: -0.200713 $\Rightarrow -11.500^{\circ}$
    \item When the initial value is 10 and 0: \
    A root is: -0.200713 $\Rightarrow -11.500^{\circ}$
    \item When the initial value is 5 and 15: \
    A root is: 9.22407 $\Rightarrow 528.500^{\circ}$
\end{enumerate}
\textbf{Discussion:} \\When the initial values used in the secant method are too far from the actual root (which is approximately $33^{\circ}$ ), the method may converge to a different root or fail to converge altogether. This happens because the secant method relies on the assumption that the function behaves linearly between the two initial points. If the initial values are in a region of the function where it has steep changes or where there are multiple roots, the method can produce erratic results. In this case, using initial values like 70 or 80 led to roots that are significantly different from the expected angle, illustrating the sensitivity of the secant method to the choice of starting points.
% ===============================================

\end{document}